import asyncio
from configparser import ConfigParser
from src64.models.user_info import UserInfo
from src64.post_report import PostReport
from src64.upload_report import Report
from main import set_log

conf = ConfigParser()
conf.read('./conf.ini', encoding='utf-8-sig')
from src64.body_analysis import BodyAnalysisDrawReport, BodyAnalysisModel
import asyncio

import datetime
import time
import sched
def time_printer():
    now = datetime.datetime.now()
    ts = now.strftime('%Y-%m-%d %H:%M:%S')
    print('do func time :', ts)
    loop_monitor()

def loop_monitor():
    s = sched.scheduler(time.time, time.sleep)  # 生成调度器
    s.enter(5, 1, time_printer, ())
    s.run()

# pd = PostData(conf, None)


# def get_report():
#     res = pd.list_check_sign_word('23003091', 1)
#     if res.code == 0 and res.data:
#         info = res.data[0]
#         if info.checkItemStatus <= 30:
#             return info

async def start_timer_loop(self):
    print('start')
    await asyncio.sleep(2)
    print('done')
    asyncio.run(self.start_timer_loop())

if __name__ == '__main__':
    set_log()

    b=BodyAnalysisDrawReport(pre_table='ConnerInfo')
    b.start()
    b.t()
    asyncio.get_event_loop().run_forever()
    # bm=BodyAnalysisModel()
    # bm.name='baibab'
    # img = 'C:\\Users\\Administrator\\Desktop\\三峡医院体检设备接口文档\\人体成分\\Bodivista-v7-x32\\bin\\image\\2A-report.jpg'
    #
    # b.draw_report(bm,'F:\\','111111')
    # print(b.conf,getattr(bm,'weight_max'))
